/*-------------------------------------------------------------------------

***************** Modification History ***********************************
   @doc
   @module UDT.h - User Definition Table Header File |
   @end
   
$Log: /SoftPay/SPK2SIM/Source/Include/udt.h $ 
 * 
 * 6     3/12/00 6:02p Page_k1
 * Remove vdGetUDTFileName()
 * 
 * 5     2/21/00 3:00p Jim_b4
 * Include file restructuring
 * 
 * 4     1/10/00 4:44p Monique_b1
 * Removed include host.h
 * 
 * 3     11/30/99 3:23p Kevin_v1
 * Removed File Name Message file usage
 * 
 * 2     11/19/99 3:18p Gary_w2
 * Corrected message processing and header includes for clerk module
 * compilation
 * 
 * 1     10/22/99 4:27p Gary_w2
 * Clerk specific files
 * 
 * 2     9/28/99 4:02p Gary_w2
 * Marking sections to change for clerk module
 * 
 * 1     7/19/99 5:32p Jim_b4
 * 
 * 1     7/19/99 4:10p Jim_b4
 * 
 * 5     7/12/99 4:04p Monique_b1
 * Changed int to short in UDT_REC structure. Removed unused parameter in
 * inDeleteUDTEntry
 * 
 * 4     6/22/99 5:32p Nick_t1
 * 
 * 3     6/14/99 12:43p Kevin_v1
 * Updated with ACT2000 DBFM Search structure support
 * 
 * 2     6/09/99 11:18a Monique_b1
 * Change headers and file names for SP 2000
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#ifndef VSUDT_H
#ifndef INTRAN_H
#define VSUDT_H

#include <fields.h>
#include <passwd.h>

#define UTT_FILE_NAME         "utt.dat"
#define ADT_FILE_NAME         "adt.dat"
/*#define SHIFT_ARRAY_SIZE 10  now in sizes.h*/


/* All total in UTT_REC are Net */
typedef struct TagUTT_REC
{
	short  inNetCount;                       /* Number of tran done: sale = +1, refund = +1, Void = -1, Adj. = +0 */
	long lnNetTotAmt;                      /* NetBase+NetTax+NetTip+NetCB+NetSurcharge */
	long lnNetBaseAmt;                     /* Net(SaleBase + VoidRefundBase - VoidSaleBase - RefundBase) */
	                                       /* for Adjustment:  +(TotalofTranAmt - TipAmt) - (OldTotalofTranAmt - OldTipAmt) */
	long lnNetTaxAmt;                      /* Net(Tax Amount) similar to NetBaseAmt Calc. except no adjustment */
	long lnNetTipAmt;                      /* Net(Tip Amount) similar to NetBaseAmt Calc. *
	                                        for Adjustment:  +(TipAmt) - (OldTipAmt) */
	long lnNetCashBack;                    /* Net(SaleCashBack - VoidSaleCashBack)   */
	long lnNetSurcharge;                   /* Net(SaleSurcharge + VoidRefundSurcharge - VoidSaleSurcharge - RefundSurcharge */
	long lnTipSale;                        /* (Base Amount of Transaction that has TipAmount != 0) - refund of (Base Amount of Transaction that has TipAmount != 0) */
	                                       /* for Adjustment: (Sale, in refund need to multiply by -1L */ 	       
	                                       /* if change from Tip to no Tip:  TipSale = -OldBaseAmount */
	                                       /* if change from no Tip to Tip:  TipSale =  BaseAmount */
	                                       /* if change from Tip to Tip:     TipSale =  TotalTransAmount - OldTotalTransAmount */
	                                       /* in VOID Sale   TipSale = -BaseAmt */
	                                       /* in VOID Refund  TipSale = BaseAmt  */
} UTT_REC;

#define SIZE_UTT_REC    sizeof(UTT_REC)

typedef struct TagUTT_KEY
{
    long   inRecNum;
  /* char   chShift; */ /* remove for clerk gw */
    char   szClerkID[CLERK_ID_SIZE + 1];
}UTT_KEY;

#define SIZE_UTT_KEY    sizeof(UTT_KEY)

extern UTT_REC srUTTRec;

typedef struct TagUTT_SKEY 
{   
    int         (*compare_func) ();
    int         inUTTKeyIdx;
    UTT_KEY     uttKey;
} UTT_SKEY;



/* file contains id's for clerks with activity in current batch  bb1 */
typedef struct TagADT
{
	char szClerkId[CLERK_ID_SIZE + 1];     /* Clerk Id */
} ADT_REC;

#define SIZE_ADT_REC    sizeof(ADT_REC)


extern char szTempMsg[MESSAGE_SIZE+1];

#ifndef VSUDT_C
extern void vdGetUTTFileName (char *pchUTTFileName);
extern int inOpenUTT (void *psrDBFPtr, char *pchFName);
extern int inCloseUTT (void *psrDBFPtr);
extern int inUTTCompareFn (UTT_KEY *psrKey, UTT_SKEY *MatchKey);
extern int inKeyReadUTT (void *psrDBFPtr, UTT_REC *psrRec, UTT_KEY *psrKey, int inKeyIdx, long *plnRecNum);
extern int inGetKeyUTTRec(void *psrDBFPtr, UTT_REC *psrRec, UTT_KEY *psrKey, int inKeyIdx, long lnDBWhat);
extern int inInsertUDTEntry (char *pchClerkId, char *pchPwd, void *psrUDTRec);
extern int inDeleteUDTEntry (char *pchClerkId, char *pchPwd);
extern int  inGetUDTPwd (char *pchClerkId, char *pchPwd);
extern int  inCheckUDTPwd (char *pchPwd, char *pchClerkId);
extern int  inCheckUDTClerkId (char *pchClerkId);
extern int  inGetUDTLogedIn (void *pobTran, char *pchClerkId);
extern int inResetUDTLogedIn (void);
extern int inUpdateUDTRecord(char *szClrk, long lnCashTip);
extern int inUpdateUTTRecord(void *pobTran, char *szClrk, int inCnt,
        long lnBase, long lnTax, long lnTip, long lnCsh, long lnSurcharge, long lnTipSale);
extern int inSetUTTAmount (void *pobTran);
extern int inGetUDTTotRecs (void);
extern int inInitUDTAmounts (void);
extern int inResetUTT (void *pobtran);
extern int inResetUTT (void *pobtran);
extern void vdGetADTFileName (char *pchADTFileName);
extern int inInsertADTEntry (char *pchClerkId, char *szADTFileName);
extern int inResetADT(void);
extern int inGetADTTotRecs (void);
extern int  inVerifyClerkPwd (char *pchPwd, char *pchClerkId);
extern int inModifyPassword (char *szClerkID, char *szPassword);
extern int inValidateClerkPwd(char *szInputPwd);

#else
void vdGetUTTFileName (char *pchUTTFileName);
int inOpenUTT (DB_FILE *psrDBFPtr, char *pchFName);
int inCloseUTT (DB_FILE *psrDBFPtr);
int inUTTCompareFn (UTT_KEY *psrKey, UTT_SKEY *MatchKey);
int inKeyReadUTT (DB_FILE *psrDBFPtr, UTT_REC *psrRec, UTT_KEY *psrKey, int inKeyIdx, long *plnRecNum);
int inGetKeyUTTRec(DB_FILE *psrDBFPtr, UTT_REC *psrRec, UTT_KEY *psrKey, int inKeyIdx, long lnDBWhat);
int inInsertUDTEntry (char *pchClerkId, char *pchPwd, void *psrUDTRec);
int inDeleteUDTEntry (char *pchClerkId, char *pchPwd);
int  inGetUDTPwd (char *pchClerkId, char *pchPwd);
int  inCheckUDTPwd (char *pchPwd, char *pchClerkId);
int  inCheckUDTClerkId (char *pchClerkId);
int  inGetUDTLogedIn (TRANSACTION_OBJECT *pobTran, char *pchClerkId);
int inResetUDTLogedIn (void);
int inUpdateUDTRecord(char *szClrk, long lnCashTip);
int inUpdateUTTRecord(TRANSACTION_OBJECT *pobTran, char *szClrk, int inCnt,
        long lnBase, long lnTax, long lnTip, long lnCsh, long lnSurcharge, long lnTipSale);
int inSetUTTAmount (TRANSACTION_OBJECT *pobTran);
int inGetUDTTotRecs (void);
int inInitUDTAmounts (void);
int inResetUTT (TRANSACTION_OBJECT *pobtran);
int inResetUTT (TRANSACTION_OBJECT *pobtran);
void vdGetADTFileName (char *pchADTFileName);
int inInsertADTEntry (char *pchClerkId, char *szADTFileName);
int inResetADT(void);
int inGetADTTotRecs (void);
int  inVerifyClerkPwd (char *pchPwd, char *pchClerkId);
int inModifyPassword (char *szClerkID, char *szPassword);
int inValidateClerkPwd(char *szInputPwd);

#endif


#endif
#endif

